<?php
/**
 * Created by PhpStorm.
 * User: zhanghua
 * Date: 18-9-23
 * Time: 下午6:16
 */

namespace app\common\controller;


use think\Controller;
use think\Response;

class SunBaseController extends Controller
{

    protected $middleware = [
//        'SunAuth' => ['except' => ['verify']]
    ];


    /**
     * 返回html代码片段
     * @param string $template 模板名称
     * @return Response
     */
    public function returnHtml($template='')
    {
        return Response::create($template, 'view');
    }

    /**
     * 返回json数据格式
     * @param int $code  业务状态
     * @param string $msg  返回说明信息
     * @param array $data  业务数据
     * @return Response
     */
    public function returnJson($code = 1, $msg = '', $data = [])
    {
        $result = [ 'code' => $code, 'msg' => $msg, 'data' => $data ? $data : new \stdClass()];

        return Response::create($result, 'Json');
    }


}

